package com.walter;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.layout.HBox;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;

/**
 * 时间选择器
 */
public class TimePicker extends DateTimePicker {

    /**
     * 初始化当前时间
     */
    public TimePicker() {
        super();
        init();
    }

    /**
     * 初始化指定时间
     *
     * @param hour   小时
     * @param minute 分钟
     * @param second 秒
     */
    public TimePicker(int hour, int minute, int second) {
        super(LocalDate.now(), hour, minute, second);
        init();
    }

    /**
     * 初始化指定时间
     *
     * @param time 时间毫秒值
     */
    public TimePicker(long time) {
        super(DateUtil.toLocalDateTime(new Date(time)));
        init();
    }

    private void init() {
        DateTimePicker dateTimePicker = super.self();
        this.hourComboBox = dateTimePicker.getHourComboBox();
        this.minuteComboBox = dateTimePicker.getMinuteComboBox();
        this.secondComboBox = dateTimePicker.getSecondComboBox();
        this.hour = dateTimePicker.getHour();
        this.minute = dateTimePicker.getMinute();
        this.second = dateTimePicker.getSecond();
        this.getChildren().removeFirst();
    }
}
